
/**
 * AppleIIGo
 * CPU class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "Motherboard.h"

#ifndef CPU_H
#define CPU_H

typedef enum {
	CPUTYPE_MOS6502,
	CPUTYPE_W65C02S,
	CPUTYPE_W65C816S,
	CPUTYPE_Z80,
};

class CPU : public Device {
public:
	static CPU * getInstance(UINT32 cpuType,
							 class Motherboard * motherboard);
	
	CPU(class Motherboard * motherboard, char * deviceName);
	
	void onDevicesConnected();
	
	virtual void assertIrq();
	virtual void clearIrq();
	virtual bool isIrqAsserted();
	virtual void triggerNmi();
	virtual void assertReset(bool isRestart);
	virtual void clearReset();
	virtual bool isResetAsserted();
	
	void setCycleIndex(UINT32 value);
	UINT32 getCycleIndex();
	void setCycleNum(UINT32 value);
	UINT32 getCycleNum();
	virtual void executeInstructions();
	
protected:
	class MMU * mmu;
	
	UINT32 cycleIndex;
	UINT32 cycleNum;
	
	UINT32 irqAssertedCount;
	UINT32 resetAssertedCount;
	bool isReset;
	bool isRestart;
	bool isNmi;
	bool isWait;
	bool isStop;
};

#endif
